const initState = {
  count: 10,
  name: "zhangsan",
};

const reducer = (state = initState, action) => {
  switch (action.type) {
    case "add":
      return {
        ...state,
        count: state.count + 1,
      };
    case "minus":
      return {
        ...state,
        count: state.count - action.n,
      };
    case "changeName":
      return {
        ...state,
        name: action.name,
      };
    default:
      return state;
  }
};

export default reducer;
